package service.impl;

import dao.CartDao;
import dao.impl.CartDaoImpl;
import entity.Cart;
import service.CartService;

import java.util.List;

public class CartServiceImpl implements CartService {
    private CartDao dao = new CartDaoImpl();

    @Override
    public int findCartCountByUserId(int user_id) {
        return dao.findCartCountByUserId(user_id);
    }

    @Override
    public List<Cart> findCartListByUserId(int i) {
        return dao.findCartListByUserId(i);
    }

    @Override
    public void addCart(Cart cart) {
        dao.addCart(cart);
    }

    /**
     * 根据Id查询购物车中的单条待购买的商品信息
     * @param cartId
     * @return
     */
    @Override
    public Cart findCartListByCartId(int cartId) {
        return dao.findCartListByCartId(cartId);
    }

    /**
     * 订单结算后，删除购物车中的信息
     * @param cartId
     */
    @Override
    public void delCartById(int cartId) {
        dao.delCartById(cartId);
    }
}
